package com.example.demo;

import com.example.demo.model.Emp;
import lombok.extern.slf4j.Slf4j;
import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@Slf4j
@MapperScan("model")
public class DemoApplication implements CommandLineRunner {

	@Autowired
	EmpMapper empMapper;

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		log.info("out");
		Emp emp = Emp.builder().name("张三").job("主管")
				.salary(Money.of(CurrencyUnit.of("CNY"), 20.0)).build();
		empMapper.save(emp);
		log.info("id = {}",emp.getId());
		empMapper.editEmp("李四",emp.getId());
		empMapper.findEmpsByNameLike("李").forEach(e->log.info(e.toString()));
		log.info("--------------");
		empMapper.findEmps().forEach(e->log.info(e.toString()));
		empMapper.findEmployee("李四","主管",Money.of(CurrencyUnit.of("CNY"), 20.0)).forEach(e->log.info("aaa {}",e.toString()));
	}



}
